﻿using System.Windows.Forms;

namespace SalaryReport
{
    public partial class SheetsCount : Form
    {
        private int count;
        private int selectedIndex;

        private int Count
        {
            set
            {
                count = value;
                lblCount.Text = string.Format("(1 - {0})", count);
            }
        }

        public int SelectedIndex
        {
            get { return selectedIndex; }
        }

        public SheetsCount(int count)
        {
            InitializeComponent();

            Count = count;
        }

        private void btnCancel_Click(object sender, System.EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void btnOk_Click(object sender, System.EventArgs e)
        {
            int index;
            if (int.TryParse(txtIndex.Text, out index))
            {
                selectedIndex = int.Parse(txtIndex.Text);
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("Введите корректное значение индекса!");
            }
        }
    }
}
